import cv2
import numpy as np

from GrayScaleFunction import Brightness, Gama_transfer, GrayScaleLiner

img_path_origin_ = r"Original.jpg"
img_path_origin_2_ = r'camera_jpeg_2_2022-07-13-19-12-25_291225186.jpg'

if __name__ == '__main__':
    img1_ = cv2.imread(img_path_origin_2_)    # 读图片

    # width_, height_, channel_ = img1_.shape   # 稍微缩放一下图片，要不屏幕显示不开
    # ratio_ = 0.4
    # height_ = int(height_ * ratio_)
    # width_ = int(width_ * ratio_)

    # img1_ = cv2.resize(img1_, (height_, width_))    # resize

    # img2_ = Brightness(img1_, 1.0, 0)    # 亮度

    # img3_ = GrayScaleLiner(img2_, r_factor=1, r_offset = 10)    # 灰度

    # img4_ = Gama_transfer(img3_, 1.8)

    # img_ = np.hstack((img1_, img3_, img4_))    # 一次堆叠 3 张，方便对比
    # cv2.imshow('img', img_)
    # cv2.waitKey(0)

    # 测试直方图均衡  >>>>>>>>>>>>>>>>>>>>>>>>>>
    cv2.imshow('origin', img1_[:,:,0])
    cv2.waitKey(0)

    dist_ = np.zeros(img1_.shape, img1_.dtype)
    dist_[:,:,0] = cv2.equalizeHist(img1_[:,:,0])
    dist_[:,:,1] = cv2.equalizeHist(img1_[:,:,1])
    dist_[:,:,2] = cv2.equalizeHist(img1_[:,:,2])

    cv2.imshow('dist', dist_)
    cv2.waitKey(0)
